package com.zqx.saller.controller;

import com.zqx.entity.Order;
import com.zqx.saller.params.OrderParam;
import com.zqx.saller.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 下单ß
     * @param authId
     * @param sign
     * @param orderParam
     * @return
     */
    @PostMapping(value = "/apply")
    public Order apply(@RequestHeader String authId, @RequestHeader String sign, @RequestBody Order order){
    //public Order apply(@RequestHeader String authId, @RequestHeader String sign, @RequestBody Order order){
        //log.info("申购请求:{}",orderParam);
        /*Order order = new Order();
        BeanUtils.copyProperties(orderParam,order);*/
        order = orderService.apply(order);
        //log.info("申购结果:{}",order);
        return order;
    }

}
